<template>
  <div class="detail-list-wrapper">
    <div 
      v-for="(item, index) of categoryList"
      :key="index"
    >
      <div class="list-item-title border-bottom">
        <span class="item-title-icon"></span>
        {{item.title}}
      </div>
      <div v-if="item.children" class="item-children">
        <!-- 自己调用自己组件不需要引入的, 自己调用其他组件才需要引入 -->
        <detail-list :categoryList="item.children"></detail-list>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DetailList',
  props: {
    categoryList: Array
  }
}
</script>

<style lang="stylus" scoped>
  .list-item-title {
    position: relative;
    width: 100%;
    height: .8rem;
    line-height: .8rem;
    font-size: .32rem;
    padding: 0 .2rem;
    text-indent: .54rem;
    font-size: .32rem

    .item-title-icon {
      // 上面的border-bottom自带了一个position: relative, 但是我们不一定知道, 所以还是在..list-item-title上写好
      display: inline-block;
      position: absolute;
      // 为什么absolute去掉后, width就变0?? 明明width已经有的, 因为是span内联元素, 所以不能设置width, 需要把它变块级或内联块
      width: .36rem;
      height: .36rem;
      top: .24rem;
      left: .26rem;
      background: url("~@assets/icon/detail.png") 0 -.45rem no-repeat;
                    /*../../../assets/*/
      margin-right: .1rem;
      -webkit-background-size: .4rem -3rem;
      background-size: .4rem 3rem;      
    }
  }

  .item-children {
    padding: 0 .3rem;
  }

  .border-bottom::before {
    // 红色作为测试用, 默认颜色看不清
    border-color: red;
  }
</style>